package com.june.springmvc.controller;

import com.june.springmvc.pojo.Items;
import com.june.springmvc.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

//@Controller
public class ItemController2 {

    @Autowired
    private ItemService itemService;

    //@RequestMapping(value = {"/itemList.action","/items"})
    public String getItemList() {

        List<Items> itemList = new ArrayList<>();
        Items items1 = new Items();
        items1.setName("S8");
        items1.setPrice(5688f);
        items1.setCreatetime(new Date());
        items1.setDetail("我已经用了一年了哟");

        Items items2 = new Items();
        items2.setName("6S");
        items2.setPrice(5888f);
        items2.setCreatetime(new Date());
        items2.setDetail("把你卖了才买的S8");

        itemList.add(items1);
        itemList.add(items2);


        //List<Items> itemList = itemService.getItemList();
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("itemList", itemList);

        return "itemList";
    }
}
